package cn.dyp.com.automaticcontrolserver.ui;


import android.app.DialogFragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.TextView;

import cn.dyp.com.automaticcontrolserver.R;

/**
 * 等待提示框
 * 
 * @author zongbingwu
 *
 */
public class LoadingDialog extends DialogFragment {
	private ImageView mImage;
	private TextView mTipTextView;
	private String mTipString = "";

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setStyle(DialogFragment.STYLE_NO_FRAME, 0);
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.load_progress_dialog, container,
				false);
		mImage = (ImageView) view.findViewById(R.id.progress_dialog_icon);
		// 设置动画
		Animation hyperspaceJumpAnimation = AnimationUtils.loadAnimation(
				getActivity(), R.anim.loading_animation);
		mImage.startAnimation(hyperspaceJumpAnimation);
		// 显示等待文字
		mTipTextView = (TextView) view.findViewById(R.id.progress_dialog_msg);
		mTipString = getString(R.string.please_wait);
		mTipTextView.setText(mTipString);

		setCancelable(false);
		return view;
	}

	public void setTipString(String tipStr) {
		mTipString = tipStr;
		if (mTipTextView != null) {
			mTipTextView.setText(mTipString);
		}
	}
}
